#!/usr/bin/env python

from heap import Heap

def main():
    # Build a Heap from an input array #
    h = Heap(input_array=[4,1,3,2,16,9,10,14,8,7])
    # print( it #)
    print( 'Heap: ' + str(h))
    # Save it as tree (pdf) #
    h.export_tree()
    # Update a Key and see the result #
    print( 'Update Key at position i=1 (value=17)')
    h.update_key(1, 17)
    print( 'Heap: ' + str(h))
    # Pop the head of the head and see the result #
    print( 'Por the head: ' + str(h.pop_head()))
    # Get the value of its new head  #
    print( "New head: " + str(h.get_head()))
    print( 'Heap: ' + str(h))
    # Insert an element and see the result #
    print( 'Insert key=6')
    h.insert(6)
    print( 'Heap: ' + str(h))
    # Sort the heap #
    print( "Heapsort: " + str(h.heapsort()))
    return 0

if __name__ == '__main__':
    main()